<?php

namespace App\Models;

class PaymentOrder extends Base
{
    /**
     * 订单类型: 充值
     */
    const ORDER_TYPE_TOP_UP = 1;

    /**
     * 订单号前缀 (两位)
     */
    const ORDER_ID_PREFIX = [
        self::ORDER_TYPE_TOP_UP => 'CZ'
    ];

    /**
     * 支付渠道: 分账通 微信
     */
    const PAYMENT_CHANNEL_FZT_WX = 1;

    /**
     * 支付渠道: 分账通 银行卡快捷支付
     */
    const PAYMENT_CHANNEL_FZT_CA = 2;

    /**
     * 支付渠道: 衫德 微信
     */
    const PAYMENT_CHANNEL_SD_WX = 3;

    /**
     * 支付渠道: 银联商务 微信公众号
     */
    const PAYMENT_CHANNEL_UMS_WX = 4;

    /**
     * 支付渠道缩写 Map
     */
    const PAYMENT_CHANNEL_ABBREVIATION_MAP = [
        self::PAYMENT_CHANNEL_FZT_WX => 'FW',
        self::PAYMENT_CHANNEL_FZT_CA => 'FC',
        self::PAYMENT_CHANNEL_SD_WX => 'SW',
        self::PAYMENT_CHANNEL_UMS_WX => 'UW',    //yang 
    ];

    /**
     * 支付状态: 生成
     */
    const PAY_STATUS_GENERATE = 1;

    /**
     * 支付状态: 完成
     */
    const PAY_STATUS_SUCCESS = 2;

    /**
     * 支付状态: 取消
     */
    const PAY_STATUS_CANCEL = 3;

    /**
     * 支付状态: 失败
     */
    const PAY_STATUS_FAIL = 4;

    /**
     * 支付渠道
     */
    const PAYMENT_CHANNEL_MAP = [
        1 => '国际银行-微信'
    ];

    public function channelFztwx()
    {
        return $this->morphedByMany(PaymentChannelFztwx::class, 'subject', 'model_has_payment_orders');
    }

    public function channelFztcashier()
    {
        return $this->morphedByMany(PaymentChannelFztcashier::class, 'subject', 'model_has_payment_orders');
    }

    public function channelFztsdwx()
    {
        return $this->morphedByMany(PaymentChannelFztsdwx::class, 'subject', 'model_has_payment_orders');
    }
    
    //yang
    public function channelFztumswx()
    {
        return $this->morphedByMany(PaymentChannelFztumswx::class, 'subject', 'model_has_payment_orders');
    }

    public function businessTopup()
    {
        return $this->morphedByMany(AgentTopUpOrder::class, 'subject', 'model_has_payment_orders');
    }
}
